package com.abc.service;

import com.abc.entity.Kecheng;
import com.abc.mapper.KechengMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KechengService {

    @Autowired
    private KechengMapper kechengMapper;

    public List<Kecheng> findAllKecheng(){
        return kechengMapper.findAllKecheng();
    }
    public String addKecheng(Kecheng kecheng){
        Kecheng kecheng1 = kechengMapper.findByKechengMingcheng(kecheng.getMingcheng());
        if(kecheng1!=null){
            return "名称已存在,添加失败";
        }
        int k = kechengMapper.insertKecheng(kecheng);
        if(k>0){
            return "添加成功";
        }else{
            return "添加失败";
        }
    }

}
